'use strict';

const moment = require('moment')

// 格式化时间
exports.formatTime = (time = new Date(), format = 'YYYY-MM-DD HH:mm:ss') => moment(time).format(format)

// 处理成功响应
exports.returnJson = ({ ctx, data = null, msg = '请求成功', code = 0, status = 200, other = {} })=> {
  ctx.body = {code, data, msg, ...other}
  ctx.status = status
}